/**
 * 
 */
package de.cbf.cam.dsa.tavern.carte.test;

import java.util.ArrayList;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

import de.cbf.cam.dsa.tavern.carte.controller.ControllerEditCarte;
import de.cbf.cam.dsa.tavern.carte.model.ModelCarte;
import de.cbf.cam.dsa.tavern.carte.model.entities.Meal;
import de.cbf.cam.dsa.tavern.carte.model.generators.TestMealGenerator;
import de.cbf.cam.dsa.tavern.carte.ui.CompositeEditCarte;

/**
 * @author Stefan Alter
 *
 */
public class UILauncher {
//testline to test svn @home
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		//create controller
		ControllerEditCarte controller = new ControllerEditCarte();
		//create and init model
		ModelCarte model = new ModelCarte();
		boolean modelInit = model.initModel(new ArrayList<Meal>()
				,TestDataProvider.provideTestIngredients()
				,TestDataProvider.provideBasicMealTypes()
				,TestDataProvider.provideAllProcessings());		
		if(! modelInit){
			System.err.println("Failed to init Model, exiting...");
			System.exit(1);
		}		
		model.setMealGenerator(new TestMealGenerator());
		
		controller.setModel(model);
		
		//create shell
		Shell shell = new Shell(Display.getCurrent(), SWT.SHELL_TRIM);
		shell.setLayout(new GridLayout(1,false));		
		shell.setSize(new Point(1024,768));
		//add composites
		CompositeEditCarte viewCarteEdit = new CompositeEditCarte(shell, SWT.NORMAL);
		viewCarteEdit.setLayoutData(new GridData(GridData.FILL_BOTH));
		//add view to controller
		controller.setView(viewCarteEdit);
		
		shell.pack();
		shell.setSize(new Point(1024,768));
		shell.open();
		while(! shell.isDisposed()){
			Display.getCurrent().readAndDispatch();
		}
	}

}
